const config = require('../config/db').mongodb
const mongoose = require('mongoose')
mongoose.Promise = global.Promise
const mongoClient = mongoose.connect(config.url, config.options)
mongoClient
  .then(
    () => console.log('connect to mongodb successfully! Pending...'),
    err => {
      console.log('connect failed.Please check you have start mongodb service at default port 27017')
      console.log(err)
      process.exit(1)
    }
  )

exports = module.exports = mongoClient
